<?php echo Modules::run('common/header') ?>

      <!-- Begin page content -->
      <div class="container content-body">
      	<div class="page-header" style="position:relative;">
  			<h1>Orders</h1>  		
		</div>

		<div id="message"></div>
        <?php $user_id = Modules::run('auth/get_user_id');
		
			  $store = $this->order_model->get_store($user_id); ?>
        
		<?php
		if(empty($order)){
				echo "<table class='table table-striped'>
						  <thead>
							<tr style='background:#E2E2E2;'>
								<th style='width: 15px;'><input type='checkbox'></th>
								<th>Order Code</th>
								<th>Customer</th>
								<td>Order Status</td>
                    			<td>Payment Status</td>
								<th>Total</th>
								<th>Date Added</th>
								<th>Date Modified</th>
								<th>Action</th>
							</tr>
						  </thead>
				</table>";
		}else{
		?>
      	<table class="table table-striped ">
              <thead>
                <tr style="background:#E2E2E2;">
                	<th style="width: 15px;"><input type="checkbox"></th>
                  	<th>Order Code</th>
                  	<th>Customer</th>
                  	<td>Order Status</td>
                    <td>Payment Status</td>
                  	<th>Total</th>
                  	<th>Date Added</th>
                  	<th>Date Modified</th>
                  	<th>Action</th>	
                </tr>
              </thead>
              <tbody>                
				<?php foreach ($order as $keys => $row): ?>
        		<tr>
                	<td><input type="checkbox"></td>
                	<td> <?php echo $row->order_cid; ?></td>
                	<td> <?php echo $row->firstname; ?> <?php echo $row->lastname ?> </td>
                	<?php $order_status = $this->order_model->get_order_status(); ?>
                	<?php foreach ($order_status as $status){?>
                		<?php if ($status->order_status_id == $row->order_status_id) {?>
                			<td> <?php echo $status->name;?> </td>
                		<?php } ?>
                	<?php } ?>
                    <?php $status_payment = $this->order_model->get_status_payment() ?>
                    <?php foreach ($status_payment as $pay){ ?>
                    	<?php if($pay->payment_status_id == $row->payment_status_id){ ?>
                        	<td><?php echo $pay->name; ?></td>
                        <?php } ?>
                    <?php } ?>
                	<td> <?php echo number_format($row->total);?> </td>
                	<td> <?php echo $row->date_added;?> </td>
                	<td> <?php echo $row->date_modified?> </td>
                	<td> <a href="<?php echo site_url('order/info/'.$row->order_id);?>">View</a><!-- | <a href="<?php echo site_url('order/update/'.$row->order_id);?>" >Edit</a>--></td>

                	
                </tr>
        		<?php endforeach; ?>                 
                
              </tbody>
            </table>
            <?php
			}
			?>
            <center>
			  <?php echo $pagination; ?>
            </center>

      </div>

<?php echo Modules::run('common/footer') ?>